$(function () {
    //tab切换
    $('.tabBtn').on('click', function () {
        $(this).addClass('current').siblings().removeClass('current');
        $(this).children().addClass('color')
        $(this).siblings().children().removeClass('color');
        var index = $(this).index();
        $('.kwBox01').eq(index).stop().fadeIn().siblings().stop().fadeOut();
    })
    //渲染最新
    $.ajax({
        url: 'http://localhost:3000/guid/new',
        type: 'get',
        success(res) {
            $.each(res,function(i,item){
                let str = $(`
                <div class="prdItem prdItemKw">
                <img src="${item.img}" alt="">
                <p>${item.text}</p>
                <div class="author">
                    <span class="price"></span>
                    <div class="zan">
                        <span><img src="./img/xinRedo.png" alt="">${item.like}</span>
                        <span><img src="./img/reply.png" alt="">${item.words}</span>
                    </div>
                </div>
            </div>
                `)
                $('.products01').prepend(str);
            })
        }
    })
    //渲染最热
    $.ajax({
        url: 'http://localhost:3000/guid/hot',
        type: 'get',
        success(res) {
            $.each(res,function(i,item){
                let str = $(`
                <div class="prdItem prdItemKw">
                <img src="${item.img}" alt="">
                <p>${item.text}</p>
                <div class="author">
                    <span class="price"></span>
                    <div class="zan">
                        <span><img src="./img/xinRedo.png" alt="">${item.like}</span>
                        <span><img src="./img/reply.png" alt="">${item.words}</span>
                    </div>
                </div>
            </div>
                `)
                $('.products02').append(str);
            })
        }
    })
})